<?php
/**
 * Created by PhpStorm.
 * User: yuanluke
 * Date: 3/14/17
 * Time: 23:32
 */

namespace App\Http\Utils\ControllerTrait;

use Illuminate\Http\Request;
use App\Http\Requests;
use Gregwar\Captcha\CaptchaBuilder;
use App\Http\Controllers\Controller;
use Log;
use App\Http\Utils\Common\OperResult;

trait VcodeTrait {

    //验证码
    public function vcode($rand) {
        $builder = new CaptchaBuilder;
        $builder->setMaxBehindLines(0)->setMaxFrontLines(0)->setDistortion(false);
        $builder->build();
        $phrase = $builder->getPhrase();

        session(['vcode'=>$phrase]);
        header("Cache-Control: no-cache, must-revalidate");
        header('Content-Type: image/jpeg');
        $builder->output();
    }

}